package zjs.dc.controller;

import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

/**
 * @Class:
 * @Author: kongcb
 * @Description: 行政处罚_信用中国:t_credit_china_penalty全量更新
 * @Date: 2021/12/15 10:31
 */
public class TCreditChinaPenalty {
    public static void main(String[] args) {
        SparkSession spark = SparkSession.builder().appName("t_credit_china_penalty").enableHiveSupport().getOrCreate();
        spark.sparkContext().setLogLevel("ERROR");
        Dataset<Row> zs_data = spark.sql("select * from xy_pdm.sgs_pub_penalty_new_tmp");
        long zs_count = zs_data.count();
        if(zs_count>0) {
            zs_data.createOrReplaceTempView("tmp_penalty");
            spark.sql("insert overwrite table a_dc_ep_incr.t_credit_china_penalty select " +
                    "md5(concat(if(cf_wsh is not null and cf_wsh!='',cf_wsh,''),company_id))," +
                    "md5(concat(if(cf_wsh is not null and cf_wsh!='',cf_wsh,''),company_id))," +
                    "company_id," +
                    "company_id," +
                    "company_name," +
                    "cf_wfxw," +
                    "cf_wsh," +
                    "CF_JDRQ," +
                    "com_province," +
                    "cf_wfxw," +
                    "CF_SY," +
                    "'1' as status," +
                    "date_format(current_date(),'yyyyMMdd')," +
                    "'1' as isadd " +
                    "from tmp_penalty");
        }
        spark.stop();
    }
}
